<?php
require_once 'BaseController.php';

/**
 * 【PC版】その他の検索(こだわり・物件種別) コントローラ
 */
class Renew_OtherSearchController extends Renew_BaseController
{

    /**
     * メインアクション
     */
    public function indexAction()
    {
        $params = $this->getParameters();

        // エリアコード名
        $this->_data['area_code_name_hokkaido'] = Apm_Config_Common::AREA_CODE_NAME_HOKKAIDO;
        $this->_data['area_code_name_tohoku'] = Apm_Config_Common::AREA_CODE_NAME_TOHOKU;
        $this->_data['area_code_name_kanto'] = Apm_Config_Common::AREA_CODE_NAME_KANTO;
        $this->_data['area_code_name_koshinetsu_hokuriku'] = Apm_Config_Common::AREA_CODE_NAME_KOSHINETSU_HOKURIKU;
        $this->_data['area_code_name_tokai'] = Apm_Config_Common::AREA_CODE_NAME_TOKAI;
        $this->_data['area_code_name_kansai'] = Apm_Config_Common::AREA_CODE_NAME_KANSAI;
        $this->_data['area_code_name_chugoku_shikoku'] = Apm_Config_Common::AREA_CODE_NAME_CHUGOKU_SHIKOKU;
        $this->_data['area_code_name_kyushu_okinawa'] = Apm_Config_Common::AREA_CODE_NAME_KYUSHU_OKINAWA;

        $map = array(
            "apart" => "賃貸アパート",
            "mansion" => "賃貸マンション",
            "kodate" => "戸建て・テラスハウス"
        );
        $map = $map + Apm_Config_Search::$KODAWARI_ID_STR_LIST;

        if ($params['conditions'][0] == 'kodawari')
        {
            $cat = $params['Category'];
        }
        else
        {
            $cat = $params['conditions'][1];
        }

        switch ($cat)
        {
            case Apm_Config_Common::AREA_CODE_NAME_TOHOKU:
                $tpl = "tohoku";
                break;
            case Apm_Config_Common::AREA_CODE_NAME_KANTO:
                $tpl = "kanto";
                break;
            case Apm_Config_Common::AREA_CODE_NAME_TOKAI:
                $tpl = "tokai";
                break;
            case Apm_Config_Common::AREA_CODE_NAME_KANSAI:
                $tpl = "kansai";
                break;
            case Apm_Config_Common::AREA_CODE_NAME_CHUGOKU_SHIKOKU:
                $tpl = 'chugoku';
                break;
            case Apm_Config_Common::AREA_CODE_NAME_KOSHINETSU_HOKURIKU:
                $tpl = 'hokuriku';
                break;
            case Apm_Config_Common::AREA_CODE_NAME_KYUSHU_OKINAWA:
                $tpl = 'kyushu';
                break;
            default:
                $tpl = 'zenkoku';
                break;
        }

        $title = $map[$params['conditions'][1]];

        if ($title == "") $title = $map[$params['conditions'][0]];

        $this->_data['headertitle'] = $title;

        if ($params['conditions'][0] == 'kodawari')
        {
            $this->_data['urlfirst'] = '/' . $params['conditions'][0] . '/' . $params['conditions'][1];
        }
        else
        {
            $this->_data['urlfirst'] = '/' . $params['conditions'][0];
        }

        $this->_data['tab_contents'] = $this->getApmHelper($tpl)->getBlock($this->_data);
        $this->displayBody('index', 'topbar2');
    }

    /**
     * SEO対策用のmetaタグに配置する文章を設定
     */
    protected function setSeoMeta()
    {
        $params = $this->getParameters();

        // こだわりの場合
        if ($params['conditions'][0] == 'kodawari')
        {
            $kodawari = $this->_data['headertitle'];

            $this->_meta_title = $kodawari . 'の賃貸物件を探す 【アパマンショップ】';
            $this->_meta_description = $kodawari . 'のお部屋を探すなら、不動産情報が満載のアパマンショップネットワーク。賃貸マンション・アパートなど、';
            $this->_meta_keywords = $kodawari . ' 賃貸,';

            // 北海道以外の場合に遷移してくるので、単純変換でOK
            if (in_array($params['Category'], Apm_Config_Search::$AREA_NAME_CODE_LIST))
            {
                $word = Apm_Config_Search::$AREA_CODE_NAME_JP_LIST[$params['Category']];

                $this->_meta_title = $word . 'で' . $this->_meta_title;
                $this->_meta_description = $word . 'で' . $this->_meta_description;
            }
        }
    }

}
?>